package org.jeecg.modules.front.util;


import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/** Native 支付下单为例 */

public class YinShengUtil {
    // 代理商编号 无需设置
    private static String agentNo;
    // 正式环境 -发起方商户号
    private static String prdSrcMerchantNo;
    // 正式环境 - 私钥密码
    private static String prdMerchantPrxPwd;
    // 正式环境 - 公钥文件 本项目中 readme 文件夹
    private static String pubKeyPath;
    // 正式环境 - 私钥文件 本项目中 readme 文件夹
    private static String prdMerchantPrx;
    // 正式环境 - 收款方银盛商户号
    private static String prdPayeeMerchantNo;
    // 正式环境 - 开放密钥
    private static String rsaPrd;
    /** 回调域名 */
    private static String notifyUrl;

    private static String wAppID;

    private static String wAppSecret;

    private static String report;


    public static void setReport(String report) {
        YinShengUtil.report = report;
    }

    public static String getReport() {
        return report;
    }


    public static void setAgentNo(String agentNo) {
        YinShengUtil.agentNo = agentNo;
    }

    public static String getAgentNo() {
        return agentNo;
    }

    public static void setPrdSrcMerchantNo(String prdSrcMerchantNo) {
        YinShengUtil.prdSrcMerchantNo = prdSrcMerchantNo;
    }

    public static String getPrdSrcMerchantNo() {
        return prdSrcMerchantNo;
    }

    public static void setPrdMerchantPrxPwd(String prdMerchantPrxPwd) {
        YinShengUtil.prdMerchantPrxPwd = prdMerchantPrxPwd;
    }

    public static String getPrdMerchantPrxPwd() {
        return prdMerchantPrxPwd;
    }

    public static void setPubKeyPath(String pubKeyPath) {
        YinShengUtil.pubKeyPath = pubKeyPath;
    }

    public static String getPubKeyPath() {
        return pubKeyPath;
    }

    public static void setPrdMerchantPrx(String prdMerchantPrx) {
        YinShengUtil.prdMerchantPrx = prdMerchantPrx;
    }

    public static String getPrdMerchantPrx() {
        return prdMerchantPrx;
    }

    public static void setPrdPayeeMerchantNo(String prdPayeeMerchantNo) {
        YinShengUtil.prdPayeeMerchantNo = prdPayeeMerchantNo;
    }

    public static String getPrdPayeeMerchantNo() {
        return prdPayeeMerchantNo;
    }

    public static void setRsaPrd(String rsaPrd) {
        YinShengUtil.rsaPrd = rsaPrd;
    }

    public static String getRsaPrd() {
        return rsaPrd;
    }

    public static void setNotifyUrl(String notifyUrl) {
        YinShengUtil.notifyUrl = notifyUrl;
    }

    public static String getNotifyUrl() {
        return notifyUrl;
    }

    public static void setWAppID(String wAppID) {
        YinShengUtil.wAppID = wAppID;
    }

    public static String getWAppID() {
        return wAppID;
    }

    public static void setWAppSecret(String wAppSecret) {
        YinShengUtil.wAppSecret = wAppSecret;
    }

    public static String getWAppSecret() {
        return wAppSecret;
    }


    public static void report(Map<String, Object> jsonObject) {
        HttpClient httpClient = HttpClients.createDefault();


        // 创建HttpPost实例，并指定URL
        HttpPost httpPost = new HttpPost(YinShengUtil.getReport());

        // 设置请求头部的Content-Type
        httpPost.setHeader("Content-Type", "application/json");

        try {
            // 创建请求内容

            // 创建ObjectMapper实例
            ObjectMapper objectMapper = new ObjectMapper();
            // 将Map转换为String
            String json = objectMapper.writeValueAsString(jsonObject);
            StringEntity requestEntity = new StringEntity(json);
            httpPost.setEntity(requestEntity);

            // 执行请求并获得响应
            HttpResponse response = httpClient.execute(httpPost);

            // 从响应中获取内容
            String responseContent = EntityUtils.toString(response.getEntity());
        } catch (Exception e) {

        }
    }



}
